package jnpf.engine.custom.behavior.factory;

import jnpf.engine.custom.behavior.impl.*;
import jnpf.engine.custom.constants.BasicActivitiConstants;
import jnpf.engine.entity.FlowTaskCirculateEntity;
import jnpf.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.model.*;
import org.flowable.engine.impl.bpmn.behavior.*;
import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 */
@Component
@Slf4j
public class CustomActivityBehaviorFactory extends DefaultActivityBehaviorFactory {



    @Override
    public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
        return new CustomUserTaskActivityBehavior(userTask);
    }


    @Override
    public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
        return new CustomParallelMultiInstanceBehavior(activity,innerActivityBehavior);
    }

    @Override
    public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
        return new CustomSequentialMultiInstanceBehavior(activity,innerActivityBehavior);
    }

    @Override
    public CallActivityBehavior createCallActivityBehavior(CallActivity callActivity) {
        return new CustomCallActivityActivityBehavior(callActivity);
    }

    @Override
    public ManualTaskActivityBehavior createManualTaskActivityBehavior(ManualTask manualTask) {
        String attributeValue = manualTask.getAttributeValue(BasicActivitiConstants.exActivitiPrefixURL, BasicActivitiConstants.extensionAttributeName);
        if(StringUtils.isBlank(attributeValue)){
            return super.createManualTaskActivityBehavior(manualTask);
        }
        else{
            return new CustomManualTaskActivityBehavior();
        }
    }



}
